<?php

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

class iJoomla_SurveysController extends JController{
	
	function display($cachable = false){		
		JRequest::setVar('view', JRequest::getCmd('view', 'iJoomla_Surveys'));
		$this->setParams();		
		parent::display($cachable);
	}
	
	function setParams(){
		$db =& JFactory::getDBO();		
		$query = $db->getQuery(true);
		$query->clear();		
		$query->select('params');
		$query->from('#__extensions');
		$query->where("name='com_surveys'");
		$db->setQuery($query);		
		$db->query();
		$result_string = $db->loadResult();
		if($result_string == "" || $result_string == "{}"){
			$params = array();
			$params["general_value"] = "MRpR";
			$params["general_date"] = "1";		
			$params["survey_name"] = "SurveyName";
			$params["survey_description"] = "SurveyDesciption";
			$params["page_name"] = "PageName";
			$params["page_description"] = "PageDesciption";
			$params["question"] = "Question";
			$params["question_description"] = "QuestionDesciption";
			$params["answer"] = "Answer";
			$params["checkbox"] = "Checkbox";
			$params["radiobutton"] = "RadioButton";
			$params["dropdownmenu"] = "DropDownMenu";
			$params["textarea"] = "TextArea";
			$params["button"]= "Button";
			$params["row_heading"] = "RowHeading";
			$params["column_heading"] = "ColumnHeading";
			$params["table_row1"] = "TableRow1";
			$params["table_row2"] = "TableRow2";
			$params["result_heading"] = "ResultHeading";
			$params["total_background"] = "TotalBackground";
			$params["popup_title"] = "PopupTitle";
			$params["popup_content"] = "PopupContent";
			$params["popup_button_row"] = "PopupButtonrow";
		
			$query = $db->getQuery(true);
			$query->clear();		
			$query->update('#__extensions');
			$query->set("`params`='".json_encode($params)."'");
			$query->where("`name`='com_surveys'");						
			$db->setQuery($query);			
			$db->query();
		}		
	}
}

?>

